import request from '@/plugins/request'
import { IResponseData } from '@/types/request-base'
import { json2FormData } from '@/utils'

// 档案变更

/**
 * 提交
 * @param {Array} data
 */
export function submitChange(data: any) {
  return request<IResponseData>({
    method: 'PUT',
    url: `/app/v1/ctmCustomerChange/info/submit`,
    data,
    loading: true
  })
}

/**
 * 经销商档案变更详情
 * @param {string} ID
 */
export function detail(id: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmCustomerChange/detail/info/${id}`
    // loading: true,
    // errorShow: true
  })
}

/**
 * 查询门店-根据客户(经销商)编码查询门店
 * @param {string} ID
 */
export function getCustomerShop(code: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmCustomerShopFiles/queryByCustomerCode/${code}`
  })
}

/**
 * 根据门店编码查询门店详情
 * @param {string} changeCode  变更单编码
 * @param {string} shopCode  门店编码
 */
export function getCustomerShopDetail({ changeCode, shopCode }: any) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmCustomerShopFiles/queryByShopCode`,
    params: { changeCode, shopCode }
  })
}
/**
 * 保存门店信息
 * @param {Array} data
 * @param {String} changeCode
 */
export function saveCustomerShop(data: any, changeCode: string) {
  return request<IResponseData>({
    method: 'post',
    url: `/app/v1/ctmCustomerChange/insertOrUpdate/shopFiles?changeCode=${changeCode}`,
    data,
    loading: true
  })
}
